<?php
/**
 * 消息中心
 *
 */
defined('InShopNC') or exit('Access Invalid!');
class message_centerModel extends Model{
    public function __construct(){
        parent::__construct('message_center');
    }
    /**
     * 消息中心列表
     * @param unknown $condition
     */
    public function listMsg($condition){
        $msg['msg_receive_id']=$condition['member_id'];
	    $list=$this->table('message_center')->where($msg)->order('msg_id asc ')->select();
        return $list;
    }
    
    /**
     * 保存消息
     * @param unknown $param
     */
    public function saveMsg($param){
     $array	= array();
     $array['msg_content'] = $param['msg_content'];
     $array['msg_type']	= $param['msg_type'];
     $array['msg_receive_id']	= $param['msg_receive_id'];
     $array['msg_receive_name']	    = $param['msg_receive_name'];
     $array['msg_time']	= $param['msg_time'];
     $array['msg_state']	= $param['msg_state'];
     $array['remark']	= $param['remark'];
     $insert_id	= $this->table('message_center')->insert($array);
     return $insert_id;
     
    }
    
    /**
     * 更新消息
     */
    public function updateMsg($condition,$data){

        $update = $this->table('message_center')->where($condition)->update($data);
        return $update;
    }
    
    /**
     * 获得系统消息数量
     */
    public function getMsgCount($condition){
        return $this->table('message_center')->where($condition)->count();
    }
    
    /**
     * 获得某一条消息
     * @param unknown $condition
     */
    public function getOneMsg($condition){
        return $this->table('message_center')->where($condition)->find();
    }
    
    /**
     * 用户删除消息
     * @param unknown $condition
     * @param unknown $data
     * @return unknown
     */
    public function editMsg($condition,$data){
        $update = $this->table('message_center')->where($condition)->update($data);
        return $update;
    }
}